package com.dream.dao.base;

/**
 * 
 * @author Evan
 * @date 2013-8-25
 * 
 */
import java.util.List;

import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Repository;

import com.dream.model.app.AppResource;
import com.dream.utils.hibernate.DetachedCriteriaBuilder;
import com.dream.utils.hibernate.DreamBaseDAO;

@Repository
public class AppResourceDAO extends DreamBaseDAO<AppResource> {

	public boolean existed(String uri){
		
		DetachedCriteriaBuilder builder = DetachedCriteriaBuilder.instance(AppResource.class);
		builder.addEq("deleted", false).addEq("uri", uri);
		
		return CollectionUtils.isNotEmpty(select(builder));
	}
	
	/***
	 * 
	 * @author evan
	 * @Revision
	 * @date 2013-10-15
	 * @return
	 */
	public List<AppResource> getList(){
		
		DetachedCriteriaBuilder builder = DetachedCriteriaBuilder.instance(AppResource.class);
		builder.addEq("deleted", false);
		builder.setOrder("moduleName|subModuleName|displayOrder");
		
		return select(builder);
	}
}
